﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.OMM.HealthMonitor.Entity.Common;

namespace Sinacor.OMM.HealthMonitor.Entity.HftProcessor
{
    [Serializable()]
    public class MessageProcessor : IHealthDataReset
    {

        HealthEntityBase _healthEntityBase;

        public MessageProcessor()
        {
            _healthEntityBase = new HealthEntityBase();
        }

        public MessageProcessor(HealthEntityBase healthEntityBase)
        {
            _healthEntityBase = healthEntityBase;
        }

        //Limite
        private decimal _limitWaitingOpenOrderAverageTime;//Tempo médio aguardando abertura da ordem
        //Informacao
        private long _totalMessages;//Total Mensagens Processadas
        private DateTime _lastMessageTime;//Horário Ultima Msg Processada
        private int _messagesPerSecond;//Número de mensagens processadas por segundo
        private decimal _waitingOpenOrderAverageTime;//Tempo médio aguardando abertura da ordem


        public decimal LimitWaitingOpenOrderAverageTime
        {
            get { return _limitWaitingOpenOrderAverageTime; }
            set 
            { 
                _limitWaitingOpenOrderAverageTime = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        public long TotalMessages
        {
            get { return _totalMessages; }
            set 
            { 
                _totalMessages = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        
        public DateTime LastMessageTime
        {
            get { return _lastMessageTime; }
            set 
            { 
                _lastMessageTime = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        
        public int MessagesPerSecond
        {
            get { return _messagesPerSecond; }
            set 
            { 
                _messagesPerSecond = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        public decimal WaitingOpenOrderAverageTime
        {
            get { return _waitingOpenOrderAverageTime; }
            set 
            { 
                _waitingOpenOrderAverageTime = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        #region IHealthDataReset Members

        public void Reset()
        {
            LimitWaitingOpenOrderAverageTime = 0;
            TotalMessages = 0;
            LastMessageTime = DateTime.Now;
            MessagesPerSecond = 0;
            WaitingOpenOrderAverageTime = 0;
        }

        #endregion
    }
}
